using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

// UI装备槽类，继承自UI_ItemSlot
public class UI_EquipmentSlot : UI_ItemSlot
{
    // 装备槽类型
    public EquipmentType slotType;

    // 在编辑器中验证时调用，设置游戏对象的名称
    private void OnValidate()
    {
        gameObject.name = "Equipment slot - " + slotType.ToString();
    }

    // 当指针按下时调用
    public override void OnPointerDown(PointerEventData eventData)
    {
        // 如果item或item.data为空，则返回
        if (item == null || item.data == null)
        {
            return;
        }

        // 卸下装备并将其添加回物品栏
        Inventory.instance.UnequipItem(item.data as ItemData_Equipment);
        Inventory.instance.AddItem(item.data as ItemData_Equipment);
        // 清理槽位
        CleanUpSlot();

        ui.itemToolTip.HideToolTip();
    }
}